package com.woke.addressactivity;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MycityAdapter extends BaseAdapter {

	private Context context;
	private ArrayList<area> list;
	private LayoutInflater mInflater;
	TextView textView = null;
	private Holder holder;
	private int current = 0;
	public MycityAdapter(Context context,ArrayList<area> list){
		this.context = context;
		this.list=list;
		mInflater = LayoutInflater.from(context);
	}
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	class Holder {
		TextView mText_money;
	}
	
	public void maksetextclor(int currpostion){
		current = currpostion;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			textView = new TextView(context);
		} else {
			textView = (TextView) convertView;
		}
		textView.setText(list.get(position).getName());
		textView.setTextSize(18);
		textView.setGravity(Gravity.CENTER);
		textView.setPadding(0, 20, 0, 20);
		textView.setTextColor(Color.BLACK);
		if(current == position){
			textView.setTextColor(Color.RED);
		}
		
//		 Holder holder = null;
//		if(convertView == null){
//			holder = new Holder();
//			convertView = mInflater.inflate(R.layout.item_myadpet_adress, null);
//			holder.mText_money = (TextView) convertView.findViewById(R.id.item_adress_text);
//			convertView.setTag(holder);
//		}else{
//			 holder = (Holder) convertView.getTag();
//		}
//		holder.mText_money.setText(list.get(position).getName());
//		holder.mText_money.setOnClickListener(new OnClickListener() {
//			
//			@Override
//			public void onClick(View v) {
//				holder.mText_money.setTextColor(Color.RED);
//			}
//		});
//		return convertView;
		return textView;
	}
	

}
